<?php

/**
 * ItemCompraNacional filter form base class.
 *
 * @package    dirsac
 * @subpackage filter
 * @author     Miguel Flores
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseItemCompraNacionalFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'articulo_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Articulo'), 'add_empty' => true)),
      'compra_id'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CompraNacional'), 'add_empty' => true)),
      'cantidad'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'costo_neto_unitario' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'observacion'         => new sfWidgetFormFilterInput(),
      'subtotal'            => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'articulo_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Articulo'), 'column' => 'id')),
      'compra_id'           => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('CompraNacional'), 'column' => 'id')),
      'cantidad'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'costo_neto_unitario' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'observacion'         => new sfValidatorPass(array('required' => false)),
      'subtotal'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('item_compra_nacional_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'ItemCompraNacional';
  }

  public function getFields()
  {
    return array(
      'id'                  => 'Number',
      'articulo_id'         => 'ForeignKey',
      'compra_id'           => 'ForeignKey',
      'cantidad'            => 'Number',
      'costo_neto_unitario' => 'Number',
      'observacion'         => 'Text',
      'subtotal'            => 'Number',
    );
  }
}
